Computer programs are used to control computers to perform various operations, e.g., image processing operations. A computer program generally includes many lines of computer code, e.g., computer instructions, which are required to control a computer to perform a desired operation. Computer programs are frequently written in a high level language such as ANSI C or C++. After a computer program is written using, e.g., an editing program, the program is then compiled using a compiler. Object code produced as a result of the compilation process is then used to control a computer to perform the desired operation for which the program was written.
The cost of developing a new computer program to perform a desired task is related to, inter alia, the amount of new code that must be written to create the computer program. This is because a programmer must spend time writing and then debugging the new code.
Various techniques have been used to reduce the amount of new code that must be written to develop a new computer program. Some of these techniques are directed to minimizing the amount of code that must be written to perform a desired operation. For example, many high level languages support the use of "for" and "while" loops which include conditional statements performed at run time. Similarly, many high level languages support function calls which involve going to memory locations where a function is stored at run time.
For most applications, the time required to determine the outcome of a conditional statement, or to make a function call at run time, is not very significant. However, in speed sensitive operations, e.g., real time image processing operations, the use of conditional statements and run time function calls can significantly impact performance. Image processing applications are often particularly sensitive to the use of operations, e.g., runtime function calls, that introduce even small execution time delays. This is because image processing routines often involve performing nearly identical operations repetitively, e.g., on several hundred thousand pixels, to process a single image. Accordingly, in such speed sensitive operations, it is desirable to avoid the use of conditional loops and run time function calls, even if this means having to duplicate many thousands of lines of code to avoid the delays that would otherwise be introduced by the use of conditional loops and run time function calls.
Other techniques directed to reducing the amount of new code that must be written for a new program often involve directly incorporating one or more previously written functions from, e.g., function libraries into the program being written. Compiler directives are frequently used for this purpose. For example, in the C programming language, several compiler directives are supported. These are frequently identified by the placement of a # sign at the beginning of the directive. The C programming language supports, e.g., a # include directive which results in the inclusion into a program of the contents of a specified file, a#define directive which results in a text substitution operation being performed, and a ## directive which causes the compiler to concatenate parameters located directly before and after the ## directive.
Because compiler directives are performed at compile time, as opposed to run time, compiler directives included in a program need not affect run time performance.
In addition to supporting compiler directives, many high level languages have attempted to make functions more general in terms of their applicability so that a single function can be used with, e.g., a variety of parameters of different types, e.g., integer, character or floating point type. The C programming language's template function is an example of a function with a reasonable degree of argument type flexibility.
Unfortunately, certain highly desirable functionalities remain missing from known high level compiled languages that would greatly enhance their ability to reuse existing code. In particular, known compiled languages do not provide any direct mechanism for generating different functions by providing different blocks of code as an argument to a general function definition at compile time. Additionally, the known compiled languages, such as the C programming language, provide no way to unroll run-time loops at compile time by copying the inner loop function code the proper number of times that it would otherwise be repeated at runtime within the runtime loop.
Because of the above described shortcomings of the known high level compiled languages some real-time compiled programs often include large amounts of code which is manually repeated, e.g., copied using a text editor. This frequently results in a large codebase which is both difficult to debug and maintain.
In view of the problems associated with the known high level compiled languages, there is a need for new methods and apparatus which will increase the amount of code that can be reused in a compiled language. In particular, it is desirable that such new methods support the passing of code segments as arguments to function definitions at compile time. Code segments passed as arguments will be referred to herein as code arguments. The ability to pass code arguments to functions would make it possible to modify the functionality of an existing library function. In addition, the new methods should be capable of generating code which unrolls runtime loops at compile time. Furthermore, any new programming methods should be compatible with one or more existing computer programming languages so that they can be implemented without requiring modifications to existing compilers.